package com.server.modules.api.service;

import com.server.common.utils.IdGen;
import com.server.modules.api.vo.list.ContactList;
import com.server.modules.sys.entity.contact.Contact;
import com.server.modules.sys.service.contact.ContactService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * @Author SilentWolf
 * @Date 2016/7/27 14:13
 */
@Service
public class ContactAPIService extends ContactService {

	@Transactional(readOnly = false)
	public void insertContact(ContactList contactList,String sessionId) {
		List<Contact> list = contactList.getContactList();

		for (Contact contact : list) {
			contact.setId(IdGen.uuid());
			contact.setCreateBy(contact.getCurrentUser());
			contact.setCreateDate(new Date());
			contact.setIsNewRecord(true);
			contact.setMemberId(sessionId);
			save(contact);
		}
	}
}
